<%@page import="org.apache.commons.lang.StringUtils"%>
<%@page import="com.maxjay.common.util.json.JsonParser"%>
<%@page import="java.util.List"%>
<%@page import="com.maxjay.component.metadata.model.Entity"%>
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="page" uri="/WEB-INF/tlds/page.tld"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
	<title>${ entity.nameCn }</title>	
	<%@ include file="/common/common.jsp" %>
	<script type="text/javascript" src="<%=request.getContextPath() %>/component/metadata/js/entity.js"></script>
	<%
		Entity entity = (Entity)request.getAttribute("entity");
		String formPlugins = entity.getEntityConfig().getViewConfig().getEntityPluginScript();
		if(StringUtils.isNotBlank(formPlugins)){
			String[] formPluginArr	= formPlugins.split(",");		
			for(String formPlugin : formPluginArr) {
	%>
	<script type="text/javascript" src="<%= request.getContextPath() %><%= formPlugin %>"></script>
	<%	
			}
		}
	%>
	<script type="text/javascript">
		var entity = Ext.util.JSON.decode('<%= JsonParser.convertObjectToJson(request.getAttribute("entity")) %>');
		var entityForm;
		var entityFormFields;
		Ext.onReady(function(){
			beforeEntityFormInit();
			Ext.QuickTips.init();
			var entityFormPanel = new Ext.form.FormPanel({
				id: 'entityForm',
				frame: true,
				title: entity.namaCn,
				layout: 'form',
				bodyStyle: 'padding: 5px',
				labelWidth: 60,
				labelAlign: 'left',
				applyTo: 'entity',
				//height: 547,
				autoHeight: true,
				items: entityFormFields,
				/*
				buttons: [
					{text: '保存', handler: save},
					{text: '重置', handler: reset}
				],
				*/
	            tbar: [{
	                iconCls:'btn-save',
	                text: '保存',
	                handler: save
	            },{
	                iconCls:'btn-undo',
	                text: '取消',
	                handler: reset
	            }]
			});
			entityFormPanel.show();
			entityForm = Ext.getCmp('entityForm').getForm();
		});
	</script>
</head>
<body>
	<div id="entity"></div>
</body>
</html>